﻿<UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             x:Class="SMS.Views.Login.LoginPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:EnterButton="clr-namespace:SMS.Common.Silverlight;assembly=SMS.Common.Silverlight"
             mc:Ignorable="d"
             xmlns:my="clr-namespace:SMS.Controls;assembly=SMS.Controls">
    <Grid x:Name="LayoutRoot">
        <Image Source="/Images/AppNameLogo.png"
               VerticalAlignment="Center" />
        <toolkit:BusyIndicator  IsBusy="{Binding IsBusy, Mode=TwoWay}"
                                HorizontalAlignment="Right"
                                BorderBrush="Blue"
                                BorderThickness="1"
                                Margin="10"
                                VerticalAlignment="Center"
                                BusyContent="{Binding BusyContent, Mode=TwoWay}">
            <Grid HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  Margin="5"
                  Background="AliceBlue">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid HorizontalAlignment="Center"
                          VerticalAlignment="Center">

                        <Grid.RowDefinitions>
                            <RowDefinition Height="30" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="2" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="2" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="2" />
                            <RowDefinition Height="Auto" />

                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="200" />
                        </Grid.ColumnDefinitions>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Loaded">
                                <i:InvokeCommandAction Command="{Binding GridControlLoadCommand}"
                                                       CommandParameter="{Binding ElementName=LayoutRoot}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <TextBlock Text="Log In"
                                   FontSize="18"
                                   FontWeight="Bold" />
                        <TextBlock Text="User Name"
                                   Grid.Row="1"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center" />
                        <TextBox Text="{Binding Path=UserName, Mode=TwoWay}"
                                 Grid.Row="1"
                                 x:Name="txt_UserName"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 Grid.Column="1">
                        </TextBox>
                        <TextBlock Text="Password"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Grid.Row="3"
                                   Margin="0,8"
                                   Width="76" />
                        <PasswordBox Password="{Binding Password, Mode=TwoWay}"
                                     x:Name="txt_Password"
                                     Grid.Row="3"
                                     HorizontalAlignment="Stretch"
                                     VerticalAlignment="Center"
                                     Grid.Column="2">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="GotFocus">
                                    <i:InvokeCommandAction Command="{Binding LoginFormGotFocusCommand}"
                                                           CommandParameter="{Binding ElementName=txt_Password}" />
                                </i:EventTrigger>
                                <i:EventTrigger EventName="PasswordChanged">
                                    <i:InvokeCommandAction Command="{Binding InputLoginFormTextChangeCommand}"
                                                           CommandParameter="{Binding ElementName=txt_Password}" />
                                </i:EventTrigger>
                                <i:EventTrigger EventName="KeyDown">
                                    <EnterButton:DefaultEnterButtonTrigger TargetName="btn_Login" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </PasswordBox>
                        <!--<TextBlock Text="Branch"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Grid.Row="5"
                                   Margin="0,8"
                                   Width="76" />
                        <my:SMSBranch Grid.Row="5" 
                                      Grid.Column="2" 
                                      SelectedBranch="{Binding SelectedMaster, Mode=TwoWay}"
                                      HorizontalAlignment="Stretch" 
                                      VerticalAlignment="Center" />
                        <HyperlinkButton x:Name="lnk_forgotPwd" Content="Forgot your password?"
                             Grid.Row="4" Grid.Column="0"
                             HorizontalAlignment="Left" VerticalAlignment="Bottom"
                             Command="{Binding Path=ForgotPasswordCommand}">
                </HyperlinkButton>-->
                        <CheckBox Content="Remember Me"
                                  VerticalAlignment="Center"
                                  Grid.Row="7"
                                  IsChecked="{Binding Path=IsRememberMe, Mode=TwoWay}"
                                  Grid.ColumnSpan="2"
                                  Margin="0,0,159,0" />
                        <Button Content="Log In"
                                x:Name="btn_Login"
                                Grid.Row="7"
                                Grid.Column="1"
                                Width="75"
                                Command="{Binding Path=LoginCommand}"
                                HorizontalAlignment="Right" />
                        <Button Content="Reset"
                                x:Name="btn_Reset"
                                Grid.Row="6"
                                Grid.Column="1"
                                Width="75"
                                Command="{Binding Path=ResetCommand}"
                                HorizontalAlignment="Right" />
                    </Grid>

                    <TextBlock Text="{Binding Path=ErrorMessage}"
                               Grid.Row="1"
                               Foreground="Red" />
                </Grid>
            </Grid>
        </toolkit:BusyIndicator>
    </Grid>
</UserControl>
